class Solution {
    public int rob(int[] nums) {
        int prev = 0, curr = 0;
        for (int i : nums) {
            int tmp = Math.max(prev+i, curr);
            prev = curr;
            curr = tmp;
        }

        return curr;
    }
}